#ifndef HTTPMGR_H
#define HTTPMGR_H


#include "Singleton.h"
#include <QString>
#include <QUrl>
#include <QObject>
#include <QNetworkAccessManager>
#include "global.h"
#include <memory>
#include <QJsonObject>
#include <QJsonDocument>
class HttpMgr:public QObject, public Singleton<HttpMgr>,
        public std::enable_shared_from_this<HttpMgr>
{
    Q_OBJECT
friend class Singleton<HttpMgr>;
public:
    ~HttpMgr();
    // 通过post发送数据
    void PostHttpReq(QUrl url, QJsonObject json, ReqId reqId, Modules mod);
private:
    HttpMgr();
    QNetworkAccessManager _manager;
    void SlotHttpFinish(ReqId reqId,QString res,ErrorCodes err,Modules mod);
signals:
    void SigHttpFinish(ReqId reqId,QString res,ErrorCodes err,Modules mod);
    void SigRegModeFinish(ReqId reqId,QString res,ErrorCodes err);
    void SigResetModeFinish(ReqId reqId,QString res,ErrorCodes err);
    void SigLoginModeFinish(ReqId reqId,QString res,ErrorCodes err);
};

#endif // HTTPMGR_H
